package com.dingwen.treasure.manage.vo;

import com.dingwen.treasure.model.entity.BaseTree;
import com.dingwen.treasure.model.entity.mybatisplus.SysDepartment;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * 　SysDepartmentForSelectVo
 * 　@author dingwen
 * 　@date 2022/6/22
 */
@ApiModel(value = "SysDepartmentForSelectVo", description = "部门下拉列表视图对象")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Accessors(chain = true)
public class SysDepartmentForSelectVo implements BaseTree {

    /**
     * 主键
     */
    @JsonIgnore
    private Long id;

    /**
     * 父节点ID
     */
    @JsonIgnore
    private Long parenId;

    /**
     * 孩子
     */
    private List children;

    /**
     * label
     */
    private String label;

    /**
     * value
     */
    private String value;



    /**
     * 设置子项(数据中转)
     *
     * @param children 儿童
     */
    @Override
    public void setChildren(List children) {
        this.children = children;
    }

    /**
     * 获取子项(数据中转)
     *
     * @return {@link List}
     */
    @Override
    public List getChildren() {
        return children;
    }

    /**
     * 获取当前元素ID
     *
     * @return {@link Long}
     */
    @Override
    public Long getId() {
        return id;
    }

    /**
     * 获取树参数id
     *
     * @return {@link Long}
     */
    @Override
    public Long getParenId() {
        return parenId;
    }
    /**
     * 参数 SysDepartment 构造： 构建树形类标进行VO转换是使用确保是 public 的
     *
     * @param sysDepartment
     */
    public SysDepartmentForSelectVo(SysDepartment sysDepartment) {
        this.label = sysDepartment.getName();
        this.value = String.valueOf(sysDepartment.getId());
    }

}
